package com.jt.www.common.service.impl;

import com.jt.www.common.service.ProductVersionService;
import com.jt.www.dao.mapper.productversion.ProductVersionMapper;
import com.jt.www.domain.enums.common.IsDeletedEnum;
import com.jt.www.domain.po.ProductVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by shaoyn on 2020/05/12.
 */
@Service
public class ProductVersionServiceImpl implements ProductVersionService {
    @Autowired
    private ProductVersionMapper productVersionMapper;

    @Override
    public String getAllProductCode(String productCode) {
        return productVersionMapper.getAllProductCode(productCode);
    }

    @Override
    public String getAllValidProductCode(String productCode) {
        return productVersionMapper.getAllValidProductCode(productCode);
    }

    @Override
    public int saveProductVersion(ProductVersion productVersion) {
        productVersion.setIsDeleted(IsDeletedEnum.NO.getValue());
        productVersion.setCreateTime(new Date());
        return productVersionMapper.insert(productVersion);
    }

    @Override
    public int updateProductVersion(ProductVersion productVersion) {
        if (null == productVersion.getId()) {
            return 0;
        }
        return productVersionMapper.updateByPrimaryKeySelective(productVersion);
    }
}
